package com.scy.java.object.StringDemo;

import java.util.Scanner;

public class StringDemo3 {
    public static void main(String[] args) {
//        //定义一个变量表示骂人的话
//        String talk = "后裔你玩什么呀，TMD";
//        //把这句话中的敏感词进行替换
////        字符串替换：talk.replace(要替换的字符串, 新的字符串)
//        String result = talk.replace("TMD", "****");
//        System.out.println(result);
        //先键盘录入要说的话
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入要说的话");
        String talkStr = scanner.next();
        //定义数组保存多个敏感词
        String[] strArr ={"TMD","GDX","ctmd","ZZ","FW","nc"};
        //把用户说的所有敏感词都替换成***
        for (int i = 0; i < strArr.length; i++) {
            talkStr = talkStr.replace(strArr[i], "***");
        }
        //打印结果
        System.out.println(talkStr);


    }
}
